﻿using System.Windows;
using Samurai.Client.DataContexts;
using System.Windows.Controls;

namespace Samurai.Client
{
    public partial class MainWindow
    {
        public MainWindow()
        {
            InitializeComponent();
            InitializeMyComponent();
        }

        private void SearchTextBoxSearched(object sender, RoutedEventArgs e)
        {
            var searchText = ((TextBox)e.Source).Text;

            MoviesDataContext.Instance.SearchCommand.Execute(searchText);            
        }

        private void InitializeMyComponent()
        {
            DataContext = MoviesDataContext.Instance;
        }

        private void MeLoaded(object sender, RoutedEventArgs e)
        {
            ((ADataContext)((FrameworkElement)sender).DataContext).OnLoaded();
        }
    }
}